package com.ruoyi.project.cms.type.controller;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.cms.type.domain.Type;
import com.ruoyi.project.cms.type.service.ITypeService;

import com.ruoyi.project.system.post.domain.Post;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/cms/type")
public class TypeController extends BaseController {
    private String prifex="cms/type";
    @Autowired
    private ITypeService typeService;

    //声明单元方法：请求转发到系统类型静态页面
    @RequestMapping()
    @RequiresPermissions("cms:type:view")
    public String view(){
        return prifex+"/typeview";
    }
    //声明单元方法:动态查询所有系统公告类型
    @RequiresPermissions("cms:type:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Type type)
    {
        //分页处理
        startPage();
        //调用业务层方法查询公告类型集合
        List<Type> list = typeService.selectTypeList(type);
        //返回TableDataInfo（相当于返回PageResult 这个对象里面有总的记录集合和总的数据分页的两个参数page和rows）
        return getDataTable(list);
    }


}
